package com.ld.collegetask.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by 樊海波 on 2017/9/20.
 */

public class SharePreference {

    Context context;

    public SharePreference(Context context) {
        this.context = context;
    }

    public void setLoginState(Boolean status) {
        ;
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean("global_is_login", status);
        editor.commit();
    }

    public boolean getLoginState() {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        return sp.getBoolean("global_is_login", false);
    }

    public void setUserId(Integer userId) {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putInt("global_user_id", userId);
        editor.commit();
    }

    public Integer getUserId() {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        return sp.getInt("global_user_id", 1);
    }

    public void setImId(String imId) {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("global_user_im_id", imId);
        editor.commit();
    }

    public String getImId() {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        return sp.getString("global_user_im_id", "");
    }

    public void setImPassword(String imPassword) {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sp.edit();
        editor.putString("global_user_im_password", imPassword);
        editor.commit();
    }

    public String getImPassword() {
        SharedPreferences sp = context.getSharedPreferences("global_collegetask_is_login", Context.MODE_PRIVATE);
        return sp.getString("global_user_im_password","");
    }


}
